
/*
#include "CronTask_server.skeleton.h"
#include "PlanManage_server.skeleton.h"
#include "PlanManage_server.skeleton.h"
#include "FileManage_server.skeleton.h"
#include "FtpManage_server.skeleton.h"
#include "ProcessManage_server.skeleton.h"
#include "ServManage_server.skeleton.h"*/
#include "SiteManage_server.skeleton.h"

#include "SystemInfomation_server.skeleton.h"

#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/processor/TMultiplexedProcessor.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/server/TNonblockingServer.h>
#include <thrift/concurrency/PosixThreadFactory.h>


using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using namespace ::apache::thrift::concurrency;
using boost::shared_ptr;

using namespace lxm;

#define THREAD_NUM 2

const int g_port = 9090;

int thrift_server_run()
{
    //创建thrift server
    shared_ptr<SystemInfomationHandler> handler_sys(new SystemInfomationHandler());
    shared_ptr<SiteManageHandler> handler_site(new SiteManageHandler());
/*    shared_ptr<ServManageHandler> handler_svr(new ServManageHandler());
    shared_ptr<ProcessManageHandler> handler_proc(new ProcessManageHandler());
    shared_ptr<FtpManageHandler> handler_ftp(new FtpManageHandler());
    shared_ptr<FileManageHandler> handler_file(new FileManageHandler());
    shared_ptr<CronTaskHandler> handler_cron(new CronTaskHandler());
    shared_ptr<PlanManageHandler> handler_plan(new PlanManageHandler());
*/
    shared_ptr<TProcessor> processor_sys(new SystemInfomationProcessor(handler_sys));
    shared_ptr<TProcessor> processor_site(new SiteManageProcessor(handler_site));
/*    shared_ptr<TProcessor> processor_svr(new ServManageProcessor(handler_svr));
    shared_ptr<TProcessor> processor_proc(new ProcessManageProcessor(handler_proc));
    shared_ptr<TProcessor> processor_ftp(new FtpManageProcessor(handler_ftp));
     shared_ptr<TProcessor> processor_file(new FileManageProcessor(handler_file));
    shared_ptr<TProcessor> processor_cron(new CronTaskProcessor(handler_cron));
    shared_ptr<TProcessor> processor_plan(new PlanManageProcessor(handler_plan));
*/



    shared_ptr<TMultiplexedProcessor> processor(new TMultiplexedProcessor());

    processor->registerProcessor("SystemInfomation", processor_sys);
    processor->registerProcessor("SiteManage", processor_site);
/*    processor->registerProcessor("ServMassage", processor_svr);
    processor->registerProcessor("ProcessorMassage", processor_proc);
    processor->registerProcessor("FtpManage", processor_ftp);
    processor->registerProcessor("FileManage", processor_file);
    processor->registerProcessor("CronTask", processor_cron);
    processor->registerProcessor("PlanManage", processor_plan);
*/

    shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());

    shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(THREAD_NUM);

    shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory> (new PosixThreadFactory());
    threadManager->threadFactory(threadFactory);
    threadManager->start();
    TNonblockingServer server(processor, protocolFactory, g_port, threadManager);

    try {
        server.serve();
    }
    catch(TException e) {
        printf("Server.serve() failed\n");
        exit(-1);
    }
    return 0;
}


int main()
{
    thrift_server_run();
    while(1) {
        sleep(10);
    }
    return 0;
}
